package com.saku.uiprojecttest.modules;/**
 * Created by liumin on 2017/2/27.
 */


import com.saku.uiprojecttest.SakuApplication;
import com.saku.uiprojecttest.http.NetManager;

import javax.inject.Inject;
import javax.inject.Singleton;

import dagger.Module;
import dagger.Provides;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * User: Missa
 * Date: 2017-02-27
 * Time: 21:49
 * Description: 提供网络请求接口
 */
@Module
public class ApiModule {
    public Retrofit mRetrofit;

    public ApiModule() {
        mRetrofit =  new Retrofit.Builder()
                .baseUrl(NetManager.BASE_URL)
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                .addConverterFactory(GsonConverterFactory.create())
                .build();
    }

//    @Singleton
//    @Provides
//    protected NetManager provideNetManager() {
//        final Retrofit retrofit = new Retrofit.Builder()
//                .baseUrl(NetManager.BASE_URL)
//                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
//                .addConverterFactory(GsonConverterFactory.create())
//                .build();
//        return retrofit.create(NetManager.class);
//    }

    @Singleton
    @Provides
    protected NetManager provideNetManager() {
        return mRetrofit.create(NetManager.class);
    }
}
